package b1.controls.basic
{
	import b1.conifg.*;
	import b1.net.*;
	import b1.scenes.home.picpane.*;
	
	import com.greensock.*;
	
	import flash.display.Sprite;
	import flash.events.*;
	import flash.text.*;
	
	public class HonourBox extends Sprite
	{
		public function HonourBox(newHonours:Object)
		{
			super();
			var MessageBoxGgr:Class = ResourceHelper.getInstance().getClassByName("MessageBox2");
			var mainSprite:Sprite = new MessageBoxGgr();
			mainSprite.alpha = alpha;
			addChild(mainSprite);

			//信息
			var messageText:TextField = new TextField();
			messageText.selectable = false;
        	messageText.autoSize = TextFieldAutoSize.CENTER;
			messageText.defaultTextFormat = new TextFormat("微软雅黑", 15, 0xF00000, true);;
			messageText.text = "恭喜你收集齐了新的套装！"
			messageText.x = (mainSprite.width - messageText.width) / 2;
			messageText.y = 115;
			addChild(messageText);
			
			//关闭按钮
			var CloseButton:Class = ResourceHelper.getInstance().getClassByName("CloseButton3");
			var closeButton:BasicButton = new BasicButton(CloseButton);
			closeButton.x = this.width - closeButton.width - 23;
			closeButton.y = 15;
			addChild(closeButton);
			closeButton.addEventListener(MouseEvent.CLICK, onCloseButtonClick);
			
			//确定按钮
			var ButtonBgr:Class = ResourceHelper.getInstance().getClassByName("ButtonBgr3");
			var buttonOK:BasicButton = new BasicButton(ButtonBgr, "确定");
			buttonOK.x = (mainSprite.width  - buttonOK.width) / 2;
			buttonOK.y = mainSprite.height - buttonOK.height - 70;
			buttonOK.addEventListener(MouseEvent.CLICK, onButtonOKClick);
			addChild(buttonOK);
			
			//套装图标
			var honourSprite:Sprite = new Sprite;
			var honourCount:int = 0;
			for (var equipType:String in newHonours)
			{
				var equipHonour:EquipHonour = new EquipHonour(parseInt(equipType), newHonours[equipType]);
				equipHonour.width = 60;
				equipHonour.height = 60;
				equipHonour.x = 100 * honourCount;
				honourSprite.addChild(equipHonour);
				honourCount++;
			}
			honourSprite.x = (this.width - honourSprite.width) / 2;
			honourSprite.y = 145;
			addChild(honourSprite);
			
			//彩纸效果
			var ColorPaper:Class = ResourceHelper.getInstance().getClassByName("ColorPaper");
			var colorPaper:BasicMc = new BasicMc(ColorPaper, 20);
			colorPaper.x = 50;
			colorPaper.y = 20;
			addChild(colorPaper);
			colorPaper = new BasicMc(ColorPaper, 20);
			colorPaper.x = this.width - 50;
			colorPaper.y = 20;
			addChild(colorPaper);
		}
		
		private function onButtonOKClick(event:MouseEvent):void
		{
			close();
		}
		
		private function onCloseButtonClick(event:MouseEvent):void
		{
			close();
		}
		
		public function close():void
        {
        	if (this.parent != null)
        	{
        		this.parent.removeChild(this);
        	}
        }
        
	}
}